extends ../public/layout
block title
    title 订单详情
block content
    -var status = orderInfo.status
    -var text = ''
    case status
        when 0: -text='待付款'
        when 1
            if orderInfo.hasReturn
                -text='售后中'
            else
                -text='待发货'
        when 2
            if orderInfo.hasReturn
                -text='售后中'
            else
                -text='待收货'
        when 3: -text='已完成'
        when 5: -text='交易关闭'
    .am-container.white-background
        .am-g.flex
            .am-u-sm-1
                i.am-inline-block.order-icon
            .am-u-sm-11.border-bottom-add
                p 订单号:#{orderInfo.orderId}
                    span.am-fr.theme-color #{text}
        if status !=0 && status !=1
            .am-g.flex(style="position:relative")
                .am-u-sm-1
                    i.am-inline-block.express-icon
                .am-u-sm-11.border-bottom-add.expressDetail(data-expressCode="#{orderInfo.expressCom}" data-expressNO="#{orderInfo.expressNO}" data-expressName="#{orderInfo.expressName}")
                    if (expInfo.Traces.length>0)
                        p.am-margin-bottom-0.theme-color 运单编号:#{orderInfo.expressNO}
                        p.am-margin-top-0 #{expInfo.Traces[0].AcceptStation}
                    else
                        p.am-margin-bottom-0.theme-color 运单编号:暂无订单
                        p.am-margin-top-0 暂无物流信息
                i.am-inline-block.more-icon.am-fr(style="position:absolute;right:20px;top:40%")
        .am-g.flex.address-box
            .am-u-sm-1
                i.am-inline-block.address-icon
            .am-u-sm-11
                p.am-margin-bottom-0 收货人&nbsp;:&nbsp;#{orderInfo.username}
                    span.am-fr #{orderInfo.mobile}
                p.am-margin-top-0 收货地址&nbsp;:&nbsp;#{orderInfo.address}
    .am-container.white-background.am-margin-top-sm
        .am-g.cart-shop-name.border-bottom-add.md-line-height.border-top-add
            .am-u-sm-7
                a(href="/home/#{orderInfo.storeId}")
                    i.am-inline-block.shop-icon
                    span.gray-color #{orderInfo.store}
            .am-u-sm-5.am-text-right
                span.theme-color  #{orderInfo.createdAt}
        each product in orderInfo.orderProducts
            .am-g.cart-shop-pro
                a(href="/product/#{product.kdProductId}")
                    img.img-responsive(src = "#{__IMAGE_HOST__}#{product.images}")
                div.order-list
                    p.am-margin-top-0.am-margin-bottom.pro-title #{product.title}
                    p.am-margin-bottom-0
                        span.md-font ￥
                            i #{product.price}
                        span.am-fr ×
                            i #{product.count}
            if  status==1 || status==2
                if !product.orderReturn
                    .am-g.border-bottom-add
                        .am-u-sm-12.am-text-right.cart-pro-handle.am-padding-xs
                            a.am-btn.am-radius.pure-gray.am-btn-xs.refundOrder(data-count="#{product.count}" data-price="#{product.price}" data-orderId="#{orderInfo.objectId}" data-productId="#{product.objectId}") 申请退款
                else
                    .am-g.border-bottom-add
                        .am-u-sm-12.am-text-right.cart-pro-handle.am-padding-xs
                            a.am-btn.am-radius.pure-gray.am-btn-xs.refundProgress( data-refundOrderId="#{product.orderReturnId}") 查看退款进度
        .am-g.border-bottom-add.flex.am-padding-top-xs.am-padding-bottom-xs
            .am-u-sm-12 买家留言:
                span.gray-color #{orderInfo.remark}
        .am-g.md-line-height
            .am-u-sm-6.gray-color 商品金额:
            .am-u-sm-6.am-text-right #{orderInfo.payPrice}￥
        .am-g.md-line-height
            .am-u-sm-6.gray-color 运费:
            .am-u-sm-6.am-text-right #{orderInfo.expressPrice}￥
        .am-g.md-line-height.border-bottom-add
            .am-u-sm-6.gray-color 商品金额:
            .am-u-sm-6.am-text-right.money-color.md-font #{orderInfo.payPrice}￥
    case status
        when 0
            .am-g.border-top-add.white-background.order-footer
                .am-u-sm-12.cart-pro-handle.am-text-right.am-padding-sm
                    a.am-btn.am-radius.pure-gray.am-btn-xs.cancelOrder(data-orderId="#{orderInfo.objectId}") 取消订单
                    a.am-btn.am-margin-left.am-radius.pure-gray.am-btn-xs.payOrder(data-orderId="#{orderInfo.objectId}" data-price="#{orderInfo.payPrice}") 去付款
        when 2
            .am-g.border-top-add.white-background.order-footer
                .am-u-sm-12.cart-pro-handle.am-text-right.am-padding-sm
                    a.am-btn.am-margin-left.am-radius.pure-gray.am-btn-xs.confirmAccept(data-orderId="#{orderInfo.objectId}") 确认收货
        when 3
            .am-g.border-top-add.white-background.order-footer
                .am-u-sm-12.cart-pro-handle.am-text-right.am-padding-sm
                    a.am-btn.am-margin-left.am-radius.pure-gray.am-btn-xs.deleteOrder(data-orderId="#{orderInfo.objectId}") 删除订单
                    a.am-btn.am-margin-left.am-radius.pure-gray.am-btn-xs.shareOrder(href="/share/#{orderInfo.objectId}") 我要晒单
        when 5
            .am-g.border-top-add.white-background.order-footer
                .am-u-sm-12.cart-pro-handle.am-text-right.am-padding-sm
                    a.am-btn.am-margin-left.am-radius.pure-gray.am-btn-xs.deleteOrder(data-orderId="#{orderInfo.objectId}") 删除订单

    #acceptModal.am-modal.am-modal-confirm(tabindex='-1')
        .am-modal-dialog
            .am-modal-bd
                | 确认收货吗
            .am-modal-footer
                span.am-modal-btn(data-am-modal-cancel='') 取消
                span.am-modal-btn(data-am-modal-confirm='') 确认
    #cancelModal.am-modal.am-modal-confirm(tabindex='-1')
        .am-modal-dialog
            .am-modal-bd
                | 确认要取消订单么？
            .am-modal-footer
                span.am-modal-btn(data-am-modal-cancel='') 取消
                span.am-modal-btn(data-am-modal-confirm='') 确认

    #deleteModal.am-modal.am-modal-confirm(tabindex='-1')
        .am-modal-dialog
            .am-modal-bd
                | 确认要删除订单么？
            .am-modal-footer
                span.am-modal-btn(data-am-modal-cancel='') 取消
                span.am-modal-btn(data-am-modal-confirm='') 确认
block javascript
    script(type="text/javascript" src = "/bower_components/amazeui/dist/js/amazeui.min.js")
    script(type="text/javascript" src = "/public/javascripts/order.js")
    script(type="text/javascript" src = "/public/javascripts/orderModal.js")
    script(type="text/javascript").
        $(function () {
            order.init();
        });
        $(function () {
            orderHandle.init();
        });


